package com.nmsl.inpatientjin.service.impl;

import java.util.List;

import com.nmsl.inpatientjin.mapper.JinPatientMapper;
import com.nmsl.nurse.mapper.EmergencyContactMapper;
import com.nmsl.sn.mapper.SnVisitRecordMapper;
import com.nmsl.system.mapper.JinDepartmentsMapper;
import com.nmsl.system.mapper.JinEmployeeMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.nmsl.inpatientjin.mapper.JinHospitalizationRegistrationMapper;
import com.nmsl.inpatientjin.domain.JinHospitalizationRegistration;
import com.nmsl.inpatientjin.service.IJinHospitalizationRegistrationService;

/**
 * 住院医生工作台Service业务层处理
 * 
 * @author jin
 * @date 2025-02-22
 */
@Service
public class JinHospitalizationRegistrationServiceImpl implements IJinHospitalizationRegistrationService 
{
    @Autowired
    private JinHospitalizationRegistrationMapper jinHospitalizationRegistrationMapper;
    @Autowired
    private JinPatientMapper jinPatientMapper;

    @Autowired
    private JinDepartmentsMapper jinDepartmentsMapper;


    @Autowired
    private JinEmployeeMapper jinEmployeeMapper;
    @Autowired
    private EmergencyContactMapper EmergencyContactMapper;
    @Autowired
    private SnVisitRecordMapper snVisitRecordMapper;
    /**
     * 查询住院医生工作台
     * 
     * @param registrationId 住院医生工作台主键
     * @return 住院医生工作台
     */
    @Override
    public JinHospitalizationRegistration selectJinHospitalizationRegistrationByRegistrationId(Long registrationId)
    {
        JinHospitalizationRegistration jinHospitalizationRegistration=new JinHospitalizationRegistration();
        jinHospitalizationRegistration.setPatient(jinPatientMapper.selectJinPatientByPatientId(jinHospitalizationRegistration.getPatientId()));
        jinHospitalizationRegistration= jinHospitalizationRegistrationMapper.selectJinHospitalizationRegistrationByRegistrationId(registrationId);
        return jinHospitalizationRegistration;
    }

    /**
     * 查询住院医生工作台列表
     * 
     * @param jinHospitalizationRegistration 住院医生工作台
     * @return 住院医生工作台
     */

    @Override
    public List<JinHospitalizationRegistration> selectJinHospitalizationRegistrationList(JinHospitalizationRegistration jinHospitalizationRegistration)
    {
        List<JinHospitalizationRegistration> list=jinHospitalizationRegistrationMapper.selectJinHospitalizationRegistrationList(jinHospitalizationRegistration);
        for(JinHospitalizationRegistration item:list){
            item.setPatient(jinPatientMapper.selectJinPatientByPatientId(item.getPatientId()));
            item.setDepartments(jinDepartmentsMapper.selectJinDepartmentsByDepartmentId(item.getDepartmentId()));
            item.setDoctor(jinEmployeeMapper.selectJinEmployeeById(item.getDoctorId()));
            item.setEmergencyContact(EmergencyContactMapper.selectByPrimaryKey(item.getEmergencyContactId()));
            item.setNurse(jinEmployeeMapper.selectJinEmployeeById(item.getNurseId()));
            item.setSnVisitRecord(snVisitRecordMapper.selectSnVisitRecordByVisitRecordId(item.getVisitRecordId()));
        }
        return list;
    }

    /**
     * 新增住院医生工作台
     * 
     * @param jinHospitalizationRegistration 住院医生工作台
     * @return 结果
     */
    @Override
    public int insertJinHospitalizationRegistration(JinHospitalizationRegistration jinHospitalizationRegistration)
    {
        return jinHospitalizationRegistrationMapper.insertJinHospitalizationRegistration(jinHospitalizationRegistration);
    }

    /**
     * 修改住院医生工作台
     * 
     * @param jinHospitalizationRegistration 住院医生工作台
     * @return 结果
     */
    @Override
    public int updateJinHospitalizationRegistration(JinHospitalizationRegistration jinHospitalizationRegistration)
    {
        return jinHospitalizationRegistrationMapper.updateJinHospitalizationRegistration(jinHospitalizationRegistration);
    }

    /**
     * 批量删除住院医生工作台
     * 
     * @param registrationIds 需要删除的住院医生工作台主键
     * @return 结果
     */
    @Override
    public int deleteJinHospitalizationRegistrationByRegistrationIds(Long[] registrationIds)
    {
        return jinHospitalizationRegistrationMapper.deleteJinHospitalizationRegistrationByRegistrationIds(registrationIds);
    }

    /**
     * 删除住院医生工作台信息
     * 
     * @param registrationId 住院医生工作台主键
     * @return 结果
     */
    @Override
    public int deleteJinHospitalizationRegistrationByRegistrationId(Long registrationId)
    {
        return jinHospitalizationRegistrationMapper.deleteJinHospitalizationRegistrationByRegistrationId(registrationId);
    }
}
